<template>
  <div id="app">
    <!-- 路由占位符，通过路由匹配到的组件在这里渲染 -->
    <router-view v-if="isRouterAlive"></router-view>

  </div>
</template>

<script>

export default {
  name: 'app',
  data () {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    // 无闪动刷新页面方法
    reload () {
      this.isRouterAlive = false
      this.$nextTick(function () {
        this.isRouterAlive = true
      })
    }
  },
  // 将函数 provide 出去
  provide () {
    return {
      reload: this.reload
    }
  },
  // 监听事件，让每个新打开的页面滚动条置顶
  watch: {
    $route: function (to, from) {
      window.pageXOffset = 0
      document.body.scrollTop = 0
      document.documentElement.scrollTop = 0
    }
  }
}
</script>

<style>
#app{
    /* background: linear-gradient(to bottom right,#9cd2f1, #f0cafc); */
    height: 100% !important;
}
.bg{
  position: relative;
}

</style>
